std::os::windows::net: add Unix-domain socket support (AF_UNIX on Windows)#147335
Closed
kouhe3 wants to merge 15 commits intorust-lang:masterfrom
Closed
std::os::windows::net: add Unix-domain socket support (AF_UNIX on Windows)#147335kouhe3 wants to merge 15 commits intorust-lang:masterfrom
kouhe3 wants to merge 15 commits intorust-lang:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
r? rust-lang/libs-api
Summary
This PR adds Unix-domain socket support to the Windows port of the standard library,
mirroring the existing APIs in
std::os::unix::net.The implementation is gated behind the unstable feature
windows_unix_domain_sockets;track issue #56533 .
Motivation / Background
Windows 10 17063+ officially support AF_UNIX.
Having the same
UnixStream/UnixListenersurface on Windows removes the need forcrates such as
mio-uds-windowsand lets cross-platform code use a single API.Acknowledgements
most of the code was transplanted from
https://github.com/Azure/mio-uds-windows
(thank you @damonbarry ).
The main delta is switching from the
winapicrate to thestd.What is added
std::os::windows::netUnixStream,UnixListener,SocketAddr,sockaddr_unAll types mirror their Unix counterparts and implement the usual
Read+Write,AsRawSocket/FromRawSocket/IntoRawSocket,AsSocket, etc.Feature gate
Testing
Can't run test because rustc ICE
How to try it locally
Notes for reviewers
sys::pal::windows.unsafeis restricted toWSASocketW,bind,connect,getsockname,getpeername.sockaddr_unconstruction follows the Unix implementation: zero-init, copy path, null-term.Dropimpl is reused fromsys::net::Socket, soclosesocketalways runs.Commit message
Checklist before clicking “Create pull request”
./x.py fmt- clean./x.py test- passed